﻿#ifndef _LOGIN_MSG_H_
#define _LOGIN_MSG_H_

#include <unordered_map>
#include "../share/message_factory.h"

typedef void(*LoginPlayerMsgProcess)(const CJsonMessageBase& msg);

class CLoginPlayerMsgFactory
{
public:
	typedef std::unordered_map< int, LoginPlayerMsgProcess >	TMsgProcess;

public:
	CLoginPlayerMsgFactory();

	LoginPlayerMsgProcess GetMsgProcess(int msg_id);

	template< typename T >void RegisteMsg(int msg_id, LoginPlayerMsgProcess process)
	{
		msg_factory_.RegistePBMsg< T >(msg_id);
		msg_process_.insert(TMsgProcess::value_type(msg_id, process));
	}

	void RegisteMsgJson(int msg_id, LoginPlayerMsgProcess process)
	{
		msg_factory_.RegistePBMsg< CJsonMessageBase >(msg_id);
		msg_process_.insert(TMsgProcess::value_type(msg_id, process));
	}

	CPBMsgFactory& GetMsgFactory() { return msg_factory_; }

private:
	CPBMsgFactory	msg_factory_;
	TMsgProcess		msg_process_;
};

#endif